/* *****************************************************************************
*
*	danizone.ch
*
*	Developer:		mda010
*	Creation date:	May 6, 2012 11:09:59 PM
*	
*	Project name:	HomegrownCuisine
*	File name:		SeasonService.java
*
*	Copyrights (C) 2012 @danizone.ch
*
*   This program is free software; you can redistribute it and/or modify
*	it under the terms of the GNU General Public License as published by
*	the Free Software Foundation; either version 2 of the License, or
*	(at your option) any later version.
*
*	This program is distributed in the hope that it will be useful,
*	but WITHOUT ANY WARRANTY; without even the implied warranty of
*	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*	GNU General Public License for more details.
*
*	Change history:	[developer]; [date];[reason for change]
*
*					mda010; May 6, 2012; created
*
***************************************************************************** */
package ch.zhaw.hgc.services.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import ch.zhaw.hgc.daos.ISeasonDao;
import ch.zhaw.hgc.entities.Season;
import ch.zhaw.hgc.services.ISeasonService;

import com.google.appengine.api.datastore.Key;

/**
 * Implementation note goes here!
 */
@Service
public class SeasonService implements ISeasonService{

	@Autowired
	private ISeasonDao seasonDao;
	
	@Override
	@Transactional(readOnly=true)
	public Season findByKey(Key key){

		return seasonDao.findById(key);
	}

	@Override
	@Transactional(readOnly=true)
	public List<Season> findAll(){

		return seasonDao.findAll();
	}

	@Override
	@Transactional
	public Season save(Season season){

		if(season.getKey() == null){
			
			season = seasonDao.create(season);
		}
		else{
			
			seasonDao.update(season);
		}
		
		return season;
	}

	@Override
	@Transactional
	public void remove(Season season){

		seasonDao.remove(season);
	}
}